package main

import (
	"fmt"
	"runtime"
	"time"
)

func main() {
	c := make(chan int, 11)
	runtime.GOMAXPROCS(runtime.NumCPU())
	fmt.Println(runtime.NumCPU())
	runtime.GOMAXPROCS(1)
	for i := 0; i < 10; i++ {
		fmt.Println("i=", i)
		//time.Sleep(1 * time.Second)
		go Go(i, c)

	}
	//close(c)
	fmt.Println("---------------")
	for v := range c {
		fmt.Println(v)
	}
}
func Go(i int, c chan int) {
	fmt.Println("go go go !!!", i)
	time.Sleep(2 * time.Second)
	c <- i

	//
	close(c)
}
